﻿using DEL.Dzb;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
using Web.Areas.Gzh.Controllers;
using Web.Models;

// For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860

namespace Web.Areas.Dzb.Controllers
{
    
    public class PartyController : DzbController<Party>
    {
        protected override void SetCurrentEntityService()
        {
            CurrentEntityService = BLLFactory.SetPartyService();
        }

        /// <summary>
        /// 获取功能树JSON数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetTreeData()
        {
            var menus = CurrentEntityService.GetEntitysByLambda(o => o.Id > 0).ToList();
            List<TreeModel> treeModels = new List<TreeModel>();
            foreach (var menu in menus)
            {
                treeModels.Add(new TreeModel() { Id = menu.Id.ToString(), Text = menu.Name, Parent = menu.ParentId == 0 ? "#" : menu.ParentId.ToString() });
            }
            return Json(treeModels);
        }

    }
}
